package com.gxy.learn.design.model.construction.faced;

import lombok.extern.slf4j.Slf4j;

/**
 * @description: 智能音响 主要用户进行交互
 * @author: gaoxueyong
 * @Date: 2022/11/7 20:46
 */
@Slf4j
public class SmartAppliancesFacade {
//    聚合电灯、电视机、空调
    private Light light;
    private TV tv;
    private AirCondition airCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }

    public void say(String message){
        if(message.contains("打开")){
            on();
        }else if(message.contains("关闭")){
            off();
        }else {
            log.info("我还听不懂 {}",message);

        }
    }
    /**
     * 一键打开家电
     * @Author gaoxueyong
     * @Date 8:53 下午 2022/11/7
     * @Param []
     * @return void
     **/
    private void on(){
        light.on();
        tv.on();
        airCondition.on();
    }
    /**
     * 一键关闭家电
     * @Author gaoxueyong
     * @Date 8:53 下午 2022/11/7
     * @Param []
     * @return void
     **/
    private void off(){
        light.off();
        tv.off();
        airCondition.off();
    }

}
